<div class="layui-form" lay-filter="sysfunc-edit-form" style="padding: 20px 30px 0 0;">
	<div class="layui-card">
		<div class="layui-card-header">权限设置</div>
		<div id="role-menu-tree"></div>
	</div>


	<div class="layui-form-item">
		<label class="layui-form-label"></label>
		<div class="layui-input-inline">
			<input type="button" lay-submit lay-filter="LAY-role-back-submit" value="确认" class="layui-btn">
		</div>
	</div>
</div>

<script>
	layui.use(['admin', 'form', 'tree'], function() {
		var $ = layui.$,
			tree = layui.tree,
			util = layui.util,
			form = layui.form;

		var demodata = [{
			title: '系统管理',
			id: 1,
			field: 'menuId_1',
			spread: true,
			children: [{
				title: '角色管理',
				id: 3,
				field: 'menuId_3',
				spread: true,
				children: [{
					title: '查询',
					id: 8,
					field: 'funcId_8'
				}]
			}]
		}];



		//基本演示
		tree.render({
			elem: '#role-menu-tree',
			data: demodata,
			showCheckbox: true //是否显示复选框
				,
			id: 'role-menu-tree-1',
			isJump: true //是否允许点击节点时弹出新窗口跳转
				,
			click: function(obj) {
				var data = obj.data; //获取当前点击的节点数据
				layer.msg('状态：' + obj.state + '<br>节点数据：' + JSON.stringify(data));
			}
		});

		//按钮事件
		util.event('lay-demo', {
			getChecked: function(othis) {
				var checkedData = tree.getChecked('test-tree-demoId1'); //获取选中节点的数据

				layer.alert(JSON.stringify(checkedData), {
					shade: 0
				});
				console.log(checkedData);
			},
			setChecked: function() {
				tree.setChecked('test-tree-demoId1', [4, 56]); //勾选指定节点
			},
			reload: function() {
				//重载实例
				tree.reload('test-tree-demoId1', {

				});

			}
		});
	});
</script>
